"""
<name>Tree Plot</name>
<author>Generated using Widget Maker written by Kyle R. Covington</author>
<description></description>
<tags>Plotting</tags>
<icon>plot.png</icon>
<inputWidgets></inputWidgets>
<outputWidgets></outputWidgets>

"""
from OWRpy import * 
from libraries.base.signalClasses.RVariable import RVariable as redRRVariable
from libraries.plotting.signalClasses.RPlotAttribute import RPlotAttribute as redRRPlotAttribute
from libraries.base.qtWidgets.lineEdit import lineEdit
from libraries.base.qtWidgets.button import button
from libraries.plotting.qtWidgets.redRPlot import redRPlot
from libraries.base.qtWidgets.graphicsView import graphicsView as redRGraphicsView
from libraries.base.qtWidgets.SearchDialog import SearchDialog
class plotTree(OWRpy): 
    def __init__(self, **kwargs):
        OWRpy.__init__(self, **kwargs)
        self.data = None
        self.RFunctionParam_x = ''
        self.plotAttributes = {}
        
        self.inputs.addInput('id0', 'x', redRRVariable, self.processx)

        
        box = OWGUI.widgetBox(self.controlArea, "Widget Box")
        #self.RFunctionParam_main = lineEdit(box, label = 'Main Title:')
        self.plotArea = redRGraphicsView(self.controlArea)
        self.plotArea.setImagePNG()
        redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction)
        # button(self.bottomAreaRight, 'Inspect Plot', callback = self.InspectPlot)
    def processx(self, data):
        if data:
            self.data = data
            self.RFunctionParam_x=data.getData()
            self.commitFunction()
        else:
            self.clearPlots()
    def commitFunction(self):
        #if self.RFunctionParam_y == '': return
        if self.RFunctionParam_x == '': return
        
        
        self.plotArea.plotMultiple(query = str(self.RFunctionParam_x), layers = ['text(%s)' % str(self.RFunctionParam_x)])
    
    def clearPlots(self):
        self.plotArea.clear()
